package main

import (
	"cubeAdmin/common/filters"
	_ "cubeAdmin/common/initialize"
	"cubeAdmin/controllers/err"
	_ "cubeAdmin/routers"
	"github.com/beego/beego/v2/client/orm"
	beego "github.com/beego/beego/v2/server/web"
	_ "github.com/go-sql-driver/mysql"
	. "github.com/logrusorgru/aurora"
	"log"
)

func main() {
	log.Print(Blue(">>>>cubeAdmin  Successfully started<<<"))

	//跨域支持
	if beego.BConfig.RunMode == "dev" {
		beego.BConfig.WebConfig.DirectoryIndex = true
		beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
	}

	fb := &filters.FilterChainBuilder{}
	beego.InsertFilterChain("/*", fb.Permission)

	//设置Session 存储桶为redis
	//beego.BConfig.WebConfig.Session.SessionProvider = "redis"

	//开启sql 日志
	if beego.BConfig.RunMode == "dev" {
		orm.Debug = true
	}

	//跳转错误页面
	beego.ErrorController(&err.ErrorController{})
	beego.Run()
}
